package com.example.caorl.jdbcaop.service.impl;

import com.example.caorl.jdbcaop.dao.IStudentDAO;
import com.example.caorl.jdbcaop.domain.Student;
import com.example.caorl.jdbcaop.service.IStudentService;

import java.util.List;

public class StudentServiceImpl implements IStudentService {

    private IStudentDAO studentDAO;

    public void setStudentDAO(IStudentDAO studentDAO) {
        this.studentDAO = studentDAO;
    }

    @Override
    public void save(Student stu) {
        studentDAO.save(stu);
        int i = 1/0;//模拟回滚
    }

    @Override
    public void delete(Long id) {
        studentDAO.delete(id);
        int i = 1/0;//模拟回滚
    }

    @Override
    public void update(Student stu) {
        studentDAO.update(stu);
        int i = 1/0;//模拟回滚
    }

    @Override
    public Student get(Long id) {
        return studentDAO.get(id);
    }

    @Override
    public List<Student> list() {
        return studentDAO.list();
    }
}
